package logic.gridNodes;

import eduni.simjava.Sim_entity;
import gridsim.net.RIPRouter;
import java.util.LinkedList;
import logic.topology.NetworkNode;

/**
 * Lokalny router moze byt spojeny s brokerom, zdrojom, uzivatelom alebo inym 
 *    lokalnym routerom
 */
public class GridRouterLocal extends NetworkNode {
    private static int count = 0;

    private static final String _obmedzenie = 
            "Local router can be connested to local broker, resource," +
            " user or another router!";
    
    public GridRouterLocal() throws Exception {
        super("GridRouterDefault123456789xtea",0,0);
        count++;
        setName("LocalRouter" + count);
}

    /**
     * <font face="">vracia null, ak je mozne vytvorit novu linku z daneho uzla
     * (este 
     *    sa nevie, aky bude koniec linky). Inak vracia dovod, preco sa nemoze 
     *    vytvorit
     * </font>
     */
    public String canCreateNewLink() {
        return null;
    }

    /**
     * Vracia null, ak moze vytvorit spojenie s danym elementom. Inak vracia
     * dovod, 
     *    preco nie. Kontroluje aj, ci uz linka s danym elementom neexistuje.
     */
    public String canCreateNewLink(NetworkNode end) {
        if ((end instanceof GridBroker) ||
            (end instanceof GridResource) ||
            (end instanceof GridUser) ||
            (end instanceof GridRouterLocal))
            return null;
        else
            return new String(_obmedzenie);
    }

    public LinkedList<Sim_entity> createGridSimEntities(String globalBrokerName, boolean trace_flag) throws Exception {
        LinkedList<Sim_entity> result = new LinkedList<Sim_entity>();
        result.add( new RIPRouter(getName(), trace_flag) );
        return result;
    }
}
